<script>
import { mapActions } from 'vuex'

export default {
  methods: {
    ...mapActions('Client', ['login']),
    ...mapActions('TravelList', ['getInitList']),

    ...mapActions('SignIn', ['signIn']),
    ...mapActions('Community', ['getPosts'])
  },

  // wx lifeCycle
  onLaunch() {
    // 进入app时,先默认获取一次用户数据
    this.login().then(() => {
      this.signIn()
      this.getInitList()
      this.getPosts()
    })

    // 版本更新提示
    const updateManager = wx.getUpdateManager()

    updateManager.onUpdateReady(function() {
      wx.showModal({
        title: '更新提示',
        content: '新版本已发布,是否更新?',
        success: function(res) {
          if (res.confirm) {
            updateManager.applyUpdate()
          }
        }
      })
    })
  }
}
</script>
